home *** CD-ROM | disk | FTP | other *** search
- Member('DOSLIB')
- Eject('Program Identification Section')
- !
- ! ┌──────────────────────┐
- ! │Program Identification├──────────────────────────────────────────────────────
- ! └──────────────────────┘
- !
- ! Program Name : Calendar.Cla
- ! Program Description : Pops-Up a Calendar and Returns a Date
- ! Version : 1.00a
- ! Date : 24 Janurary 1994
- ! Programmer : Trevor G. Leybourne
- !
- ! ┌──────────────────────┐
- ! │Invocation Structure ├─────────────────────────────────────────────────────
- ! └──────────────────────┘
- !
- ! Functions Called : Calendar - Actual Pop-Up Calendar
- !
- ! ┌──────────────────────┐
- ! │Input/Output ├─────────────────────────────────────────────────────
- ! └──────────────────────┘
- !
- ! Datafiles Read : None
- ! Datafiles Updated : None
- !
- ! ┌──────────────────────┐
- ! ┌┤Functional Description├────────────────────────────────────────────────────┐
- ! │└──────────────────────┘ │
- ! │ │
- ! │ This program is simply a Pop-Up Calendar │
- ! └────────────────────────────────────────────────────────────────────────────┘
- !
- ! ┌──────────────────────┐
- ! ┌┤Modification History ├────────────────────────────────────────────────────┐
- ! │└──────────────────────┘ │
- ! │ Ver. Date Programmer Summary of Changes │
- ! ├────────────────────────────────────────────────────────────────────────────┤
- ! │ │
- ! │ 1.01 24-Jan-1994 Trevor G. Leybourne Original Production Version │
- ! │ │
- ! └────────────────────────────────────────────────────────────────────────────┘
- !
- OMIT('╝')
- ╔════════════════════════════════════════════════════════════════════════════╗
- ║ Calculator - Displays the Pop-Up Calculator ║
- ╚════════════════════════════════════════════════════════════════════════════╝
- Calendar Function(Default:Date)
- !
- ! ---------------------------------------------------------------------------
- ! Local Variables
- ! ---------------------------------------------------------------------------
- !
- Group,Pre(Cal) ! Group of Local Variables
- Date_Today Long ! Todays Real Date
- Date_Selected Long ! Actual Date Selected
- Date_Saved Long ! Date Saved
- Show_Index Long ! Screen Display Index
- Save_Index Long ! Save the Index
- Day Long ! Current Day
- Month Long ! Current Month
- Year Long ! Current Year
- Base_Date Long ! Base Date
- Base_Col Long ! Base Column
- Last_Day Long ! Last Day of the Month
- .
-
- Transform_Table Group ! This Table Transforms Col Within Row
- String('<01,07,13,19,25,31,37>')
- String('<02,08,14,20,26,32,38>')
- String('<03,09,15,21,27,33,39>')
- String('<04,10,16,22,28,34,40>')
- String('<05,11,17,23,29,35,41>')
- String('<06,12,18,24,30,36,42>')
- .
- Transform_Array Byte,Dim(42),Over(Transform_Table)
-
- Month_Table Group ! Names of the Months
- String('January February March April ')
- String('May June July August ')
- String('SeptemberOctober November December ')
- .
- Month_Array String(9),Dim(12),Over(Month_Table)
- !
- ! ---------------------------------------------------------------------------
- ! Screen Declarations
- ! ---------------------------------------------------------------------------
- !
- Calendar_Screen SCREEN(19,28),PRE(Scr),SHADOW,CUA,COLOR(1)
- !dimensions=25,80,25,80
- !style=D:\CLARION\DEVELOP\DOSLIB\CLARION.STY
- ROW(7,5) PAINT(6,20),COLOR(15)
- ROW(1,1) STRING('█{10}'),COLOR(3)
- COL(11) STRING('Calendar'),COLOR(2)
- COL(19) STRING('█{10}'),COLOR(3)
- ROW(5,5) STRING('Su'),COLOR(6)
- COL(8) STRING('Mo'),COLOR(6)
- COL(11) STRING('Tu'),COLOR(6)
- COL(14) STRING('We'),COLOR(6)
- COL(17) STRING('Th'),COLOR(6)
- COL(20) STRING('Fr'),COLOR(6)
- COL(23) STRING('Sa'),COLOR(6)
- ROW(6,4) STRING('▄{22}'),COLOR(78)
- ROW(13,4) STRING('▀{22}'),COLOR(78)
- ROW(19,1) STRING('█▄{26}█'),COLOR(3)
- REPEAT(6)
- ROW(7,4) STRING('█'),COLOR(78)
- ROW(7,25) STRING('█'),COLOR(78)
- .
- REPEAT(17)
- ROW(2,1) STRING('█'),COLOR(3)
- ROW(2,28) STRING('█'),COLOR(3)
- .
- Show_Actual_Date ROW(3,5) STRING(@s20),COLOR(8)
- REPEAT(6,7),EVERY(1,3),INDEX(Cal:Show_Index)
- Show_Calendar ROW(7,5) STRING(@n_2b)
- COL(5) POINT(1,2),USE(?Select_Date),COLOR(42)
- .
- ROW(15,10) BUTTON(' '),SHADOW,KEY(PgUpKey),USE(?Last_Month),COLOR(17,18,39,19,20)
- COL(4) BUTTON(' '),SHADOW,KEY(CtrlPgUp),USE(?Last_Year),COLOR(17,18,39,19,20)
- COL(17) BUTTON(' '),SHADOW,KEY(PgDnKey),USE(?Next_Month),COLOR(17,18,39,19,20)
- COL(22) BUTTON(' '),SHADOW,KEY(CtrlPgDn),USE(?Next_Year),COLOR(17,18,39,19,20)
- ROW(17,4) BUTTON(' Ok '),SHADOW,KEY(EnterKey),USE(?Calendar_OK),COLOR(17,18,39,19,20)
- COL(17) BUTTON(' Today '),SHADOW,USE(?Goto_Today),COLOR(17,18,39,19,20)
- .
- !
- ! ---------------------------------------------------------------------------
- ! Code Section
- ! ---------------------------------------------------------------------------
- !
- Code
- GetStyles('Clarion.Sty')
- SetMouse(1,1)
- Open(Calendar_Screen)
-
- If ~Omitted(1) then
- Cal:Date_Today = Default:Date
- Cal:Date_Selected = Default:Date
- Cal:Date_Saved = 0
- .
- If Cal:Date_Today = 0 or Omitted(1) then
- Cal:Date_Today = Today()
- Cal:Date_Selected = Today()
- Cal:Date_Saved = 0
- .
- Do Display_Ptr
-
- Loop
- Alert
- Alert(LeftKey,RightKey)
- Alert(HomeKey,UpKey)
- Alert(EndKey,DownKey)
- Alert(PgUpKey)
- Alert(PgDnKey)
- Cal:Date_Saved = Cal:Date_Selected
- Accept
- !
- ! ---------------------------------------------------------
- ! Check the Key that has been Pressed
- ! ---------------------------------------------------------
- !
- Case Keycode()
- Of LeftKey
- Cal:Date_Selected = Date(Cal:Month,Cal:Day,Cal:Year) - 1
- Do Display_Ptr
- Of RightKey
- Cal:Date_Selected = Date(Cal:Month,Cal:Day,Cal:Year) + 1
- Do Display_Ptr
- Of UpKey
- Cal:Date_Selected = Date(Cal:Month,Cal:Day,Cal:Year) - 7
- Do Display_Ptr
- Of DownKey
- Cal:Date_Selected = Date(Cal:Month,Cal:Day,Cal:Year) + 7
- Do Display_Ptr
- Of PgUpKey
- Cal:Month -= 1
- If Cal:Month < 1 then Cal:Month = 12; Cal:Year -=1.
- Cal:Date_Selected = Date(Cal:Month,Cal:Day,Cal:Year)
- Do Display_Ptr
- Of PgDnKey
- Cal:Month += 1
- If Cal:Month > 12 then Cal:Month = 1; Cal:Year +=1.
- Cal:Date_Selected = Date(Cal:Month,Cal:Day,Cal:Year)
- Do Display_Ptr
- .
- !
- ! ---------------------------------------------------------
- ! Check the selected Field
- ! ---------------------------------------------------------
- !
- Case Field()
- Of ?Last_Month
- Cal:Month -= 1
- If Cal:Month < 1 then Cal:Month = 12; Cal:Year -=1.
- Cal:Date_Selected = Date(Cal:Month,Cal:Day,Cal:Year)
- Do Display_Calendar
- Of ?Last_Year
- Cal:Year -= 1
- Cal:Date_Selected = Date(Cal:Month,Cal:Day,Cal:Year)
- Do Display_Calendar
- Of ?Next_Month
- Cal:Month += 1
- If Cal:Month > 12 then Cal:Month = 1; Cal:Year +=1.
- Cal:Date_Selected = Date(Cal:Month,Cal:Day,Cal:Year)
- Do Display_Calendar
- Of ?Next_Year
- Cal:Year += 1
- Cal:Date_Selected = Date(Cal:Month,Cal:Day,Cal:Year)
- Do Display_Calendar
- Of ?Calendar_Ok
- Break
- Of ?Goto_Today
- Cal:Date_Selected = Today()
- Do Display_Ptr
- Select(?Select_Date)
- Of ?Select_Date
- Cal:Date_Selected = Date(Month(Cal:Date_Selected),Scr:Show_Calendar,Year(Cal:Date_Selected))
- Do Display_Ptr
- . .
- Alert
- Close(Calendar_Screen)
- Return(Cal:Date_Selected)
- !
- ! ---------------------------------------------------------------------------
- ! Check the Current Date Pointer and Redisplay the Calendar is Applicable
- ! ---------------------------------------------------------------------------
- !
- Display_Ptr Routine
-
- Scr:Show_Actual_Date = Center(Format(Cal:Date_Selected,@d4),Size(Scr:Show_Actual_Date))
- Cal:Day = Day (Cal:Date_Selected)
- Cal:Month = Month(Cal:Date_Selected)
- Cal:Year = Year (Cal:Date_Selected)
-
- If Month(Cal:Date_Selected) <> Month(Cal:Date_Saved) or |
- Year (Cal:Date_Selected) <> Year (Cal:Date_Saved) then
- Do Display_Calendar
- Else
- If Day(Cal:Date_Selected) <> Day(Cal:Date_Saved) then
- Cal:Show_Index = Transform_Array[Day(Cal:Date_Selected)+Cal:Base_Col]
- If Scr:Show_Calendar = '' or Scr:Show_Calendar = '00' then
- Do Display_Calendar
- . . .
- Exit
- !
- ! ---------------------------------------------------------------------------
- ! Display the Calendar based on the Date in CAL:DATE_SELECTED
- ! ---------------------------------------------------------------------------
- !
- Display_Calendar Routine
-
- Cal:Save_Index = Cal:Show_Index
- Cal:Base_Date = Date(Cal:Month,1,Cal:Year)-1
- Cal:Base_Col = (Cal:Base_Date + 1) % 7
- Cal:Last_Day = Day(Date(Cal:Month+1,1,Cal:Year)-1)
-
- Loop I# = 1 to 42
- Cal:Show_Index = Transform_Array[I#]
- Scr:Show_Calendar = ''
- .
- Loop I# = 1 to Cal:Last_Day
- Cal:Show_Index = Transform_Array[I#+Cal:Base_Col]
- Scr:Show_Calendar = Format(I#,@n_2b)
- .
- Cal:Show_Index = Transform_Array[Cal:Day+Cal:Base_Col]
- Select(?Select_Date)
- Exit
-